/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package controller;

import model.Cliente;
import org.hibernate.HibernateException;
import org.hibernate.Transaction;

/**
 *
 * @author Enrique
 */
public class ClienteController {
    
    
    public static void guardarCliente(Cliente cliente){
        
        Transaction transaccion = null;
        try {
        transaccion = ConexionBDHibernate.getSesion().beginTransaction();
        
        ConexionBDHibernate.getSesion().save(cliente);
        transaccion.commit();
        
         // atrapo excepciones    
            } catch (HibernateException e){ 
                transaccion.rollback();
                e.printStackTrace();
            } finally {
                ConexionBDHibernate.getSesion().close(); // cierro la sesion (BD)
            }
    }
    
}
